package com.type.dao;

import java.util.ArrayList;
import java.util.HashMap;

import javax.annotation.Resource;

import org.springframework.orm.ibatis.SqlMapClientTemplate;
import org.springframework.stereotype.Repository;

import com.type.vo.ServiceRequestVO;

/**
 * 복무신청 관련 CRUD를 위한 DAO클래스
 * @author hyem55
 * @since 2013.05.21
 */
@Repository("ServiceRequestDAO")
public class ServiceRequestDAO {

	@Resource(name="sqlMapClientTemplate")
	private SqlMapClientTemplate sqlmap;
	
	/*	 */
	
	public int selectSequenceNo(){
		return (Integer)sqlmap.queryForObject("serviceRequest.selectSequenceNo");
	}
	/*복무신청 등록*/
	public void insertServiceRequest(ServiceRequestVO serviceRequestVO){
		sqlmap.insert("serviceRequest.insertServiceRequest", serviceRequestVO);
		//return serviceRequestVO.getName();//신청자 이름 리턴
	}
	/*신청한 복무기록 전체리스트*/
	@SuppressWarnings("unchecked")
	public ArrayList<ServiceRequestVO> selectServiceRequestList(){
		return (ArrayList<ServiceRequestVO>)sqlmap.queryForList("serviceRequest.selectServiceRequestList");
	}
	/*전체리스트에서 선택한 복무신청 기록 상세보기*/
	public ServiceRequestVO selectServiceRequestViewByNo(int requestNo){
		return (ServiceRequestVO)sqlmap.queryForObject("serviceRequest.selectServiceRequestViewByNo",requestNo);
	}
	
	@SuppressWarnings("unchecked")
	public ArrayList<ServiceRequestVO> selectServiceRequestListByDate(String startDate, String endDate, String name) {
		HashMap<String,String> map = new HashMap<String,String>();
		map.put("startDate", startDate);
		map.put("endDate", endDate);
		map.put("name", name);
		return (ArrayList<ServiceRequestVO>) sqlmap.queryForList("serviceRequest.selectServiceListByDate",map);
	}
}
